package gui;

import modelo.Enfermero;
import modelo.Paciente;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import java.awt.Frame;
import org.eclipse.swt.awt.SWT_AWT;
import java.awt.Panel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JRootPane;
import org.eclipse.swt.layout.GridLayout;

import business.Adquisidor_Electro;
import business.electro.Electrocardiograma;



/**
 * ZetCode Java SWT tutorial
 *
 * This program creates a simple toolbar
 *
 * @author rodrigo girlando
 * 
 */


public class MainPage {

    private static Login login;
	private Shell shlSaerEmergentologa;
    private Image newi;
    private Image opei;
    private Image quii;
    private Image ecgpng;
    private Image send;
    private Image header;
    private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
    private ToolBar toolBar;
    private Text text;
    private Text text_1;
    private Text text_2;
    private Text text_3;
    private final CTabFolder tabFolder;
    Enfermero enfermero = new Enfermero();
    Paciente paciente = new Paciente();
    boolean desconocido = false;
    private Text text_6;
    private Text text_4;
    ToolItem item3;
    private ToolBar toolBar_1;
    Section sctnNewSection;
    Electrocardiograma ecg;
    Adquisidor_Electro adq;
    Panel panelECG;
    JPanel jPanelECG;
    Frame frame;
    private JPanel[] paneles;
    


    public MainPage(Display display) {

        shlSaerEmergentologa = new Shell(display);
        
        shlSaerEmergentologa.setText("SAER - Emergentolog\u00EDa");

        initUI();

        shlSaerEmergentologa.setSize(1000, 650);
        shlSaerEmergentologa.setLocation(10, 10);
        
        tabFolder = new CTabFolder(shlSaerEmergentologa, SWT.BORDER);
        tabFolder.setVisible(false);
        FormData fd_tabFolder = new FormData();
        fd_tabFolder.bottom = new FormAttachment(toolBar, 555, SWT.BOTTOM);
        fd_tabFolder.top = new FormAttachment(toolBar, 22);
        fd_tabFolder.left = new FormAttachment(toolBar, 10, SWT.LEFT);
        fd_tabFolder.right = new FormAttachment(toolBar_1, 0, SWT.RIGHT);
        tabFolder.setLayoutData(fd_tabFolder);
        formToolkit.adapt(tabFolder);
        formToolkit.paintBordersFor(tabFolder);
        tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
            
            CTabItem tbtmNuevaVisita = new CTabItem(tabFolder, SWT.NONE);
            tbtmNuevaVisita.setText("Nueva Atenci\u00F3n");
            
                Composite composite = new Composite(tabFolder, SWT.NONE);
                tbtmNuevaVisita.setControl(composite);
                formToolkit.paintBordersFor(composite);
                composite.setLayout(new FormLayout());
                
                Section sctnDatosDelPaciente = formToolkit.createSection(composite, Section.TWISTIE | Section.TITLE_BAR);
                sctnDatosDelPaciente.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                FormData fd_sctnDatosDelPaciente = new FormData();
                fd_sctnDatosDelPaciente.right = new FormAttachment(100, -3);
                fd_sctnDatosDelPaciente.left = new FormAttachment(0);
                fd_sctnDatosDelPaciente.top = new FormAttachment(0);
                fd_sctnDatosDelPaciente.bottom = new FormAttachment(100, -370);
                sctnDatosDelPaciente.setLayoutData(fd_sctnDatosDelPaciente);
                formToolkit.paintBordersFor(sctnDatosDelPaciente);
                sctnDatosDelPaciente.setText("DATOS DEL PACIENTE");
                sctnDatosDelPaciente.setExpanded(true);
                
                Composite composite_1 = formToolkit.createComposite(sctnDatosDelPaciente, SWT.NONE);
                formToolkit.paintBordersFor(composite_1);
                sctnDatosDelPaciente.setClient(composite_1);
                
                Label lblNombre = new Label(composite_1, SWT.NONE);
                lblNombre.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                lblNombre.setBounds(10, 10, 79, 25);
                formToolkit.adapt(lblNombre, true, true);
                lblNombre.setText("Nombre:");
                
                Label lblApellido = new Label(composite_1, SWT.NONE);
                lblApellido.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                lblApellido.setBounds(255, 10, 79, 25);
                formToolkit.adapt(lblApellido, true, true);
                lblApellido.setText("Apellido:");
                
                text = new Text(composite_1, SWT.BORDER);
                text.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                text.setBounds(95, 7, 142, 31);
                formToolkit.adapt(text, true, true);
                
                text_1 = new Text(composite_1, SWT.BORDER);
                text_1.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                text_1.setBounds(340, 7, 166, 31);
                formToolkit.adapt(text_1, true, true);
                
                Label lblEdad = new Label(composite_1, SWT.NONE);
                lblEdad.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                lblEdad.setBounds(10, 51, 49, 25);
                formToolkit.adapt(lblEdad, true, true);
                lblEdad.setText("Edad:");
                
                text_2 = new Text(composite_1, SWT.BORDER);
                text_2.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                text_2.setBounds(95, 48, 80, 31);
                formToolkit.adapt(text_2, true, true);
                
                Label lblDni = new Label(composite_1, SWT.NONE);
                lblDni.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                lblDni.setBounds(562, 10, 40, 25);
                formToolkit.adapt(lblDni, true, true);
                lblDni.setText("DNI:");
                
                text_3 = new Text(composite_1, SWT.BORDER);
                text_3.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                text_3.setBounds(614, 7, 116, 31);
                formToolkit.adapt(text_3, true, true);
                
                Group grpSexo = new Group(composite_1, SWT.NONE);
                grpSexo.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                grpSexo.setText("Sexo");
                grpSexo.setBounds(255, 41, 264, 61);
                formToolkit.adapt(grpSexo);
                formToolkit.paintBordersFor(grpSexo);
                
                Button btnMasculino = new Button(grpSexo, SWT.RADIO);
                btnMasculino.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                btnMasculino.setBounds(26, 27, 115, 25);
                formToolkit.adapt(btnMasculino, true, true);
                btnMasculino.setText("Masculino");
                
                Button btnFemenino = new Button(grpSexo, SWT.RADIO);
                btnFemenino.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                btnFemenino.setBounds(146, 27, 112, 25);
                formToolkit.adapt(btnFemenino, true, true);
                btnFemenino.setText("Femenino");
                
                Button btnDesconocido = new Button(composite_1, SWT.CHECK);
                btnDesconocido.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));

                btnDesconocido.setBounds(575, 63, 139, 25);
                formToolkit.adapt(btnDesconocido, true, true);
                btnDesconocido.setText("Desconocido");
                

                
   
                
                sctnNewSection = formToolkit.createSection(composite, Section.TWISTIE | Section.TITLE_BAR);
                sctnNewSection.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                FormData fd_sctnNewSection = new FormData();
                fd_sctnNewSection.bottom = new FormAttachment(100, -10);
                fd_sctnNewSection.top = new FormAttachment(0, 140);
                fd_sctnNewSection.right = new FormAttachment(100, -3);
                fd_sctnNewSection.left = new FormAttachment(0);
                sctnNewSection.setLayoutData(fd_sctnNewSection);
                formToolkit.paintBordersFor(sctnNewSection);
                sctnNewSection.setText("DATOS CLINICOS");
                sctnNewSection.setExpanded(true);
                
                Composite composite_2 = new Composite(sctnNewSection, SWT.NONE);
                formToolkit.adapt(composite_2);
                formToolkit.paintBordersFor(composite_2);
                sctnNewSection.setClient(composite_2);
                
                sctnNewSection.setVisible(false);
                Button btnContinuar = new Button(composite_1, SWT.NONE);
                btnContinuar.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                btnContinuar.addMouseListener(new MouseAdapter() {
                	@Override
                	public void mouseDown(MouseEvent e) {
                		sctnNewSection.setVisible(true);
                	}
                });
                btnContinuar.setBounds(758, 48, 96, 35);
                formToolkit.adapt(btnContinuar, true, true);
                btnContinuar.setText("Continuar");
                composite_2.setLayout(new FormLayout());
                
                
                Label lblTemperatura = new Label(composite_2, SWT.NONE);
                FormData fd_lblTemperatura = new FormData();
                fd_lblTemperatura.top = new FormAttachment(0, 25);
                fd_lblTemperatura.left = new FormAttachment(0, 10);
                lblTemperatura.setLayoutData(fd_lblTemperatura);
                lblTemperatura.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                formToolkit.adapt(lblTemperatura, true, true);
                lblTemperatura.setText("Temperatura:");
                
                Label lblNivelDeGlucosa = new Label(composite_2, SWT.NONE);
                FormData fd_lblNivelDeGlucosa = new FormData();
                fd_lblNivelDeGlucosa.top = new FormAttachment(0, 64);
                fd_lblNivelDeGlucosa.left = new FormAttachment(0, 10);
                lblNivelDeGlucosa.setLayoutData(fd_lblNivelDeGlucosa);
                lblNivelDeGlucosa.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                formToolkit.adapt(lblNivelDeGlucosa, true, true);
                lblNivelDeGlucosa.setText("Nivel de Glucosa:");
                
                Group grpPresin = new Group(composite_2, SWT.NONE);
                FormData fd_grpPresin = new FormData();
                fd_grpPresin.bottom = new FormAttachment(0, 314);
                fd_grpPresin.right = new FormAttachment(0, 184);
                fd_grpPresin.top = new FormAttachment(0, 106);
                fd_grpPresin.left = new FormAttachment(0, 10);
                grpPresin.setLayoutData(fd_grpPresin);
                grpPresin.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                grpPresin.setText("Presi\u00F3n");
                formToolkit.adapt(grpPresin);
                formToolkit.paintBordersFor(grpPresin);
                
                Label lblDistolica = new Label(grpPresin, SWT.NONE);
                lblDistolica.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                lblDistolica.setBounds(10, 46, 77, 25);
                formToolkit.adapt(lblDistolica, true, true);
                lblDistolica.setText("Sistolica:");
                
                Label lblDistolica_1 = new Label(grpPresin, SWT.NONE);
                lblDistolica_1.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                lblDistolica_1.setBounds(10, 121, 80, 25);
                formToolkit.adapt(lblDistolica_1, true, true);
                lblDistolica_1.setText("Distolica:");
                
                Spinner spinner_4 = new Spinner(grpPresin, SWT.BORDER);
                spinner_4.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                spinner_4.setBounds(100, 43, 63, 31);
                formToolkit.adapt(spinner_4);
                formToolkit.paintBordersFor(spinner_4);
                
                Spinner spinner_5 = new Spinner(grpPresin, SWT.BORDER);
                spinner_5.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                spinner_5.setBounds(100, 118, 63, 31);
                formToolkit.adapt(spinner_5);
                formToolkit.paintBordersFor(spinner_5);
                
                Label lblPulso = new Label(composite_2, SWT.NONE);
                FormData fd_lblPulso = new FormData();
                fd_lblPulso.top = new FormAttachment(0, 28);
                fd_lblPulso.left = new FormAttachment(0, 266);
                lblPulso.setLayoutData(fd_lblPulso);
                lblPulso.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                formToolkit.adapt(lblPulso, true, true);
                lblPulso.setText("Pulso:");
                
                Label lblOxgeno = new Label(composite_2, SWT.NONE);
                FormData fd_lblOxgeno = new FormData();
                fd_lblOxgeno.top = new FormAttachment(0, 67);
                fd_lblOxgeno.left = new FormAttachment(0, 266);
                lblOxgeno.setLayoutData(fd_lblOxgeno);
                lblOxgeno.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                formToolkit.adapt(lblOxgeno, true, true);
                lblOxgeno.setText("Ox\u00EDgeno:");
                
                text_6 = new Text(composite_2, SWT.BORDER);
                FormData fd_text_6 = new FormData();
                fd_text_6.right = new FormAttachment(0, 244);
                fd_text_6.top = new FormAttachment(0, 22);
                fd_text_6.left = new FormAttachment(0, 181);
                text_6.setLayoutData(fd_text_6);
                text_6.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                formToolkit.adapt(text_6, true, true);
                
                Spinner spinner = new Spinner(composite_2, SWT.BORDER);
                FormData fd_spinner = new FormData();
                fd_spinner.bottom = new FormAttachment(0, 141);
                fd_spinner.right = new FormAttachment(0, 89);
                fd_spinner.top = new FormAttachment(0, 106);
                fd_spinner.left = new FormAttachment(0, 89);
                spinner.setLayoutData(fd_spinner);
                formToolkit.adapt(spinner);
                formToolkit.paintBordersFor(spinner);
                
                Spinner spinner_1 = new Spinner(composite_2, SWT.BORDER);
                FormData fd_spinner_1 = new FormData();
                fd_spinner_1.top = new FormAttachment(0, 25);
                fd_spinner_1.left = new FormAttachment(0, 356);
                spinner_1.setLayoutData(fd_spinner_1);
                spinner_1.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                formToolkit.adapt(spinner_1);
                formToolkit.paintBordersFor(spinner_1);
                
                Spinner spinner_3 = new Spinner(composite_2, SWT.BORDER);
                FormData fd_spinner_3 = new FormData();
                fd_spinner_3.top = new FormAttachment(0, 61);
                fd_spinner_3.left = new FormAttachment(0, 181);
                spinner_3.setLayoutData(fd_spinner_3);
                spinner_3.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                formToolkit.adapt(spinner_3);
                formToolkit.paintBordersFor(spinner_3);
                
                text_4 = new Text(composite_2, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
                FormData fd_text_4 = new FormData();
                fd_text_4.bottom = new FormAttachment(0, 314);
                fd_text_4.right = new FormAttachment(0, 539);
                fd_text_4.top = new FormAttachment(0, 137);
                fd_text_4.left = new FormAttachment(0, 190);
                text_4.setLayoutData(fd_text_4);
                text_4.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                formToolkit.adapt(text_4, true, true);
                
                Label lblSntomas = new Label(composite_2, SWT.NONE);
                FormData fd_lblSntomas = new FormData();
                fd_lblSntomas.top = new FormAttachment(0, 106);
                fd_lblSntomas.left = new FormAttachment(0, 192);
                lblSntomas.setLayoutData(fd_lblSntomas);
                lblSntomas.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.BOLD));
                formToolkit.adapt(lblSntomas, true, true);
                lblSntomas.setText("S\u00EDntomas:");
                
                Spinner spinner_2 = new Spinner(composite_2, SWT.BORDER);
                FormData fd_spinner_2 = new FormData();
                fd_spinner_2.top = new FormAttachment(0, 64);
                fd_spinner_2.left = new FormAttachment(0, 356);
                spinner_2.setLayoutData(fd_spinner_2);
                spinner_2.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
                formToolkit.adapt(spinner_2);
                formToolkit.paintBordersFor(spinner_2);
                
                Label label = new Label(composite_2, SWT.SEPARATOR | SWT.VERTICAL);
                FormData fd_label = new FormData();
                fd_label.bottom = new FormAttachment(0, 324);
                fd_label.right = new FormAttachment(0, 545);
                fd_label.top = new FormAttachment(0);
                fd_label.left = new FormAttachment(0, 545);
                label.setLayoutData(fd_label);
                formToolkit.adapt(label, true, true);
                
                
                
                
                //ECG
                
                Composite composite_3 = new Composite(composite_2, SWT.EMBEDDED);
                FormData fd_composite_3 = new FormData();
                fd_composite_3.bottom = new FormAttachment(0, 314);
                fd_composite_3.right = new FormAttachment(0, 933);
                fd_composite_3.top = new FormAttachment(0, 10);
                fd_composite_3.left = new FormAttachment(0, 551);
                composite_3.setLayoutData(fd_composite_3);
                formToolkit.adapt(composite_3);
                formToolkit.paintBordersFor(composite_3);
                composite_3.setLayout(new GridLayout(1, false));
                
                frame = SWT_AWT.new_Frame(composite_3);
                
                panelECG = new Panel();
                frame.add(panelECG);
//                panelECG.setLayout(new BorderLayout(0, 0));

                

        		ecg = new Electrocardiograma();
        		adq = new Adquisidor_Electro();
        		
                
                
                ToolBar toolBar_2 = new ToolBar(composite_2, SWT.FLAT | SWT.RIGHT);
                FormData fd_toolBar_2 = new FormData();
                fd_toolBar_2.bottom = new FormAttachment(0, 95);
                fd_toolBar_2.right = new FormAttachment(0, 529);
                fd_toolBar_2.top = new FormAttachment(0, 26);
                fd_toolBar_2.left = new FormAttachment(0, 450);
                toolBar_2.setLayoutData(fd_toolBar_2);
                formToolkit.adapt(toolBar_2);
                formToolkit.paintBordersFor(toolBar_2);
                
                ToolItem toolItem = new ToolItem(toolBar_2, SWT.SHADOW_OUT);
                toolItem.setToolTipText("Comenzar Medici\u00F3n");
                toolItem.setImage(ecgpng);
                

                toolItem.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                    	paneles = new JPanel[2];
            			adq.empezar_adquisicion_muestras();
            			ecg = adq.da_electro();
            			jPanelECG = new JPanel();
            			
            			
            			panelECG.add(jPanelECG);
            			jPanelECG.add(new Graficador_Electro(ecg, 0));
            			
                    }
                });
                


     
                
                
                //
                
                
                login = new Login(display);
                if (login.isOk()){
                	enfermero.setNombre(login.getNombreEnfermero());
                	enfermero.setId(login.getEnfermeroId());
                	enfermero.setApellido(login.getApellidoEnfermero());
                	
                }
                Label lblBienvenido = formToolkit.createLabel(shlSaerEmergentologa, "Bienvenido "+enfermero.getNombre()+" " +enfermero.getApellido(), SWT.CENTER);
                lblBienvenido.setFont(SWTResourceManager.getFont("Segoe UI", 18, SWT.NORMAL));
                lblBienvenido.setAlignment(SWT.LEFT);
                lblBienvenido.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
                FormData fd_lblBienvenido = new FormData();
                fd_lblBienvenido.bottom = new FormAttachment(tabFolder, -6);
                fd_lblBienvenido.top = new FormAttachment(0);
                fd_lblBienvenido.right = new FormAttachment(toolBar_1, -192);
                fd_lblBienvenido.left = new FormAttachment(toolBar, 191);
                lblBienvenido.setLayoutData(fd_lblBienvenido);

    
        
       // shlSaerEmergentologa.open();

        if (login.isOk()){
        	 shlSaerEmergentologa.setMaximized(true);
        	 shlSaerEmergentologa.open();
        	
        }

        
        while (!shlSaerEmergentologa.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }

    public void initUI() {

        Device dev = shlSaerEmergentologa.getDisplay();

        try {
            newi = new Image(dev, "emergency.png");
            opei = new Image(dev, "message.png");
            quii = new Image(dev, "quit.png");
            ecgpng = new Image(dev, "ecg.png");
            send = new Image(dev, "send.png");
            header = new Image(dev, "header.png");
            

        } catch (Exception e) {
            System.out.println("Cannot load images");
            System.out.println(e.getMessage());
            System.exit(1);
        }
        shlSaerEmergentologa.setLayout(new FormLayout());

        toolBar = new ToolBar(shlSaerEmergentologa, SWT.SHADOW_OUT);
        FormData fd_toolBar = new FormData();
        fd_toolBar.top = new FormAttachment(0);
        fd_toolBar.left = new FormAttachment(0);
        toolBar.setLayoutData(fd_toolBar);

        ToolItem item1 = new ToolItem(toolBar, SWT.PUSH);
        item1.setToolTipText("Nueva Atenci\u00F3n");
        item1.setImage(newi);

        ToolItem item2 = new ToolItem(toolBar, SWT.PUSH);
        item2.setToolTipText("Ver Mensajes");
        item2.setImage(opei);
        
        new ToolItem(toolBar, SWT.SEPARATOR);
        new ToolItem(toolBar, SWT.SEPARATOR);
        new ToolItem(toolBar, SWT.SEPARATOR);
        new ToolItem(toolBar, SWT.SEPARATOR);

        item3 = new ToolItem(toolBar, SWT.PUSH);
        item3.setToolTipText("Enviar");
        item3.setImage(send);
        item3.setEnabled(false);
        
//        new ToolItem(toolBar, SWT.SEPARATOR);
//
//        ToolItem item3 = new ToolItem(toolBar, SWT.PUSH);
//        item3.setImage(quii);

        toolBar.pack();
//
        item3.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {

            }
        });
//        
        
        item1.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
            	tabFolder.setVisible(true);
            	tabFolder.setSelection(0);
            	 item3.setEnabled(true);
            
            }
        });

        
        toolBar_1 = new ToolBar(shlSaerEmergentologa, SWT.SHADOW_OUT);
        FormData fd_toolBar_1 = new FormData();
        fd_toolBar_1.top = new FormAttachment(0);
        fd_toolBar_1.right = new FormAttachment(100, -10);
        toolBar_1.setLayoutData(fd_toolBar_1);

        
        ToolItem tltmNewItem = new ToolItem(toolBar_1, SWT.PUSH);
        tltmNewItem.setToolTipText("Salir");
        
        tltmNewItem.setImage(quii);

        
        
        
        tltmNewItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
               
            	//shell.getDisplay().dispose();
            	shlSaerEmergentologa.close();
            }
        });
    
    
    
    
    }

//    public static void main(String[] args) {
//        Display display = new Display();
//
//    	new MainPage(display);
//       display.dispose();
//    
//        
//    }
}
